package com.example.springboothello.conf;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Bean
    public StringToDateConverter stringToDateConverter() {
        return new StringToDateConverter();
    }

    @Override
    public void addFormatters(FormatterRegistry registry) {
        // 注册自定义的日期转换器
        registry.addConverter(stringToDateConverter());
    }
}
